home *** CD-ROM | disk | FTP | other *** search
- UNIT Globals;
-
- {+----------------------------------------------------------------------------+
- | |
- | HodgePodge: An example Apple IIGS Desktop application |
- | |
- | Written in 65816 assembler and APW C by the Apple IIGS Tools Team |
- | Translated to TML Pascal by TML Systems, Inc. |
- | Modified by Ben Koning for "Programmer's Introduction to the Apple IIGS" |
- | |
- | Copyright (c) 1986-87 by Apple Computer, Inc. |
- | Copyright (c) 1987 by TML Systems, Inc. |
- | |
- | -------------------------------- |
- | |
- | Pascal UNIT "GLOBALS.PAS" : Global data structs and init routine |
- | |
- +----------------------------------------------------------------------------+}
-
-
-
- INTERFACE
-
- USES
- HPIntfData, {HodgePodge Apple IIGS Toolbox Interface Units}
- HPIntfProc,
- HPIntfPdos;
-
- CONST
- ScreenMode = $80; {640 mode}
- MaxX = 640; {Max X clamp (should correspond to ScreenMode}
- MaxScan = 160; {Max size of scan line}
-
- AppleMenuID = 300;
- AboutItem = 301;
- FileMenuID = 400;
- OpenItem = 401;
- CloseItem = 255; {For DA's}
- SaveAsItem = 403;
- ChoosePItem = 405;
- PageSetItem = 406;
- PrintItem = 407;
- QuitItem = 409;
- EditMenuID = 500;
- UndoItem = 250; {For DA's}
- CutItem = 251; {For DA's}
- CopyItem = 252; {For DA's}
- PasteItem = 253; {For DA's}
- ClearItem = 254; {For DA's}
- WindowsMenuID = 600;
- NoWindowsItem = 601;
- FirstWindItem = 2000; {Allocated dynamically starting at 2000}
- FontsMenuID = 700;
- FontItem = 701;
- MonoItem = 702;
-
- FirstWind = 0; {Lower bound of WindowList}
- LastWind = 15; {Upper bound of WindowList}
-
-
-
- TYPE
- WindDataH = ^WindDataP; {RefCon data for our windows}
- WindDataP = ^WindDataRec; {...carried along with wind data}
- WindDataRec = record
- Name: Str255;
- MenuStr: Str255;
- MenuID: integer;
- Flag: integer; {0 = Paint, 1 = Font}
- case integer of
- 0 : (theFont: FontID;
- isMono : boolean);
- 1 : (pict: Handle);
- end;
-
-
-
- VAR
- MyMemoryID : integer; {Application ID assigned by Memory Mgr}
- Done : boolean; {True when quitting}
- ToolsZeroPage : Handle; {Handle to Zero page memory for Tools}
- Event : WmTaskRec; {All events are returned here}
-
- AppleMenuStr : Str255; {For creating menus}
- FileMenuStr : Str255;
- EditMenuStr : Str255;
- WindowMenuStr : Str255;
- FontMenuStr : Str255;
-
- NoWindStr : String [40]; {Menu Item String for "No Windows..."}
- MonoStr : String [40];
- ProStr : String [40];
-
- LastWindow : GrafPortPtr; {The Front Window last time through event l
- dummy : integer; {*** >!< Possible compiler bug?}
- DesiredFont : FontID; {Indicates current selected font}
- isMonoFont : boolean; {Flag indicates if mono spacing selected}
- myReply : SFReplyRec;
- PictHndl : Handle;
-
- WIndex : integer; {Count of number of windows open}
- WindowList : {List of up to 15 open windows}
- array [firstWind..lastWind] of GrafPortPtr;
-
- PlsWtTemp : DialogTemplate;
- PlsWtItem : ItemTemplate;
-
- AppleIcon : record
- boundsRect : Rect;
- data : array [1..34] of
- packed array [1..16] of byte;
- end;
-
-
-
- procedure InitGlobals; {Setup variables}
- PROCEDURE HPStuffHex (thingPtr : Ptr; s : Str255); {Store hex}
-
-
-
-
-
- IMPLEMENTATION
-
-
-
- PROCEDURE HPStuffHex (thingPtr : Ptr; s : Str255);
-
- {>!< This routine will be implemented in TML Pascal V1.1. For now,
- we define it ourselves. StuffHex stores bytes (expressed as a string
- of hexadecimal digits) into any data structure, and is based on the
- StuffHex procedure in Macintosh QuickDraw. The resolution of this
- routine is on byte boundaries.}
-
- var Iterator : integer;
- StringIndex : integer;
-
- begin {of HPStuffHex}
- for Iterator := 0 to Length (s) - 1 do begin
- StringIndex := (Iterator * 2) + 1;
- thingPtr^ := Hex2Int (StringPtr (longint (@s) + StringIndex),2);
- thingPtr := pointer (longint (thingPtr) + 1);
- end;
- end; {of HPStuffHex}
-
-
-
-
-
- procedure InitGlobals;
-
- {Initialize global data variables, including the PlsWtTemp used by
- ShowPleaseWaitDialog, the menu strings used by the menu bar setup
- routines in MENU.PAS, and the apple icon used by the "about..."
- item dialog routine in DIALOG.PAS}
-
- begin {of InitGlobals}
- with PlsWtTemp do begin
- SetRect (dtBoundsRect,120,30,520,80);
- dtVisible := true;
- dtRefCon := 0;
- dtItemList [0] := pointer (0); {We will insert ptr to item here}
- dtItemList [1] := nil; {Null-terminated}
- end;
-
- AppleMenuStr := concat ('>>@\N300X\0',
- '==About HodgePodge...\N301\0',
- '==-\N302D\0.');
- FileMenuStr := concat ('>> File \N400\0',
- '==Open...\N401*Oo\0',
- '==Close\N255D\0',
- '==Save As...\N403D\0',
- '==-\N404D\0',
- '==Choose Printer...\N405\0',
- '==Page Setup...\N406D\0',
- '==Print...\N407*PpD\0',
- '==-\N408D\0',
- '==Quit\N409*Qq\0.');
- EditMenuStr := concat ('>> Edit \N500D\0',
- '==Undo\N250*Zz\0',
- '==-\N501D\0',
- '==Cut\N251*Xx\0',
- '==Copy\N252*Cc\0',
- '==Paste\N253*Vv\0',
- '==Clear\N254\0.');
- WindowMenuStr := concat('>> Window \N600D\0',
- '== No Windows Allocated\N601D\0.');
- FontMenuStr := concat ('>> Fonts \N700\0',
- '==Display Font...\N701*Ff\0',
- '==Display Font as Mono-spaced\N702*Mm\0.');
-
- LastWindow := nil;
-
- NoWindStr := '==No Windows Allocated\N601D\0.';
-
- MonoStr := '=Display Font as Mono-spaced';
- ProStr := '=Display Font as Proportional';
- isMonoFont := false;
-
- with DesiredFont do begin
- famNum := $FFFE;
- fontStyle := 0;
- fontSize := 8;
- end;
-
- WIndex := 0; {No windows open yet}
-
- SetRect (AppleIcon.boundsRect,0,0,64,34);
- HPStuffHex (@AppleIcon.data[1], '00000000000000000000000000000000');
- HPStuffHex (@AppleIcon.data[2], '0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0');
- HPStuffHex (@AppleIcon.data[3], '0F0000000000000000000000000000F0');
- HPStuffHex (@AppleIcon.data[4], '0F0FFFFFFFFFFFFFFFFFFFFFFFFFF0F0');
- HPStuffHex (@AppleIcon.data[5], '0F0FFFFFFFFFFFFFFFFFF88FFFFFF0F0');
- HPStuffHex (@AppleIcon.data[6], '0F0FFFFFFFFFFFFFFFF8888FFFFFF0F0');
- HPStuffHex (@AppleIcon.data[7], '0F0FFFFFFFFFFFFFFF88888FFFFFF0F0');
- HPStuffHex (@AppleIcon.data[8], '0F0FFFFFFFFFFFFFF88888FFFFFFF0F0');
- HPStuffHex (@AppleIcon.data[9], '0F0FFFFFFFFFFFFF888888FFFFFFF0F0');
- HPStuffHex (@AppleIcon.data[10],'0F0FFFFFFFFFFFFF88888FFFFFFFF0F0');
- HPStuffHex (@AppleIcon.data[11],'0F0FFFFFFFFFFFFF8888FFFFFFFFF0F0');
- HPStuffHex (@AppleIcon.data[12],'0F0FFFFFF8888FFF88FF8888FFFFF0F0');
- HPStuffHex (@AppleIcon.data[13],'0F0FFFF88888888FFF88888888FFF0F0');
- HPStuffHex (@AppleIcon.data[14],'0F0FFF888888888888888888888FF0F0');
- HPStuffHex (@AppleIcon.data[15],'0F0FFeeeeeeeeeeeeeeeeeeeeFFFF0F0');
- HPStuffHex (@AppleIcon.data[16],'0F0FFeeeeeeeeeeeeeeeeeeeFFFFF0F0');
- HPStuffHex (@AppleIcon.data[17],'0F0FFeeeeeeeeeeeeeeeeeeFFFFFF0F0');
- HPStuffHex (@AppleIcon.data[18],'0F0FF666666666666666666FFFFFF0F0');
- HPStuffHex (@AppleIcon.data[19],'0F0FF666666666666666666FFFFFF0F0');
- HPStuffHex (@AppleIcon.data[20],'0F0FF666666666666666666FFFFFF0F0');
- HPStuffHex (@AppleIcon.data[21],'0F0FF4444444444444444444FFFFF0F0');
- HPStuffHex (@AppleIcon.data[22],'0F0FF44444444444444444444FFFF0F0');
- HPStuffHex (@AppleIcon.data[23],'0F0FFF444444444444444444444FF0F0');
- HPStuffHex (@AppleIcon.data[24],'0F0FFF555555555555555555555FF0F0');
- HPStuffHex (@AppleIcon.data[25],'0F0FFF555555555555555555555FF0F0');
- HPStuffHex (@AppleIcon.data[26],'0F0FFFF5555555555555555555FFF0F0');
- HPStuffHex (@AppleIcon.data[27],'0F0FFFF1111111111111111111FFF0F0');
- HPStuffHex (@AppleIcon.data[28],'0F0FFFFF11111111111111111FFFF0F0');
- HPStuffHex (@AppleIcon.data[29],'0F0FFFFFF111111FFF111111FFFFF0F0');
- HPStuffHex (@AppleIcon.data[30],'0F0FFFFFFF1111FFFFF1111FFFFFF0F0');
- HPStuffHex (@AppleIcon.data[31],'0F0FFFFFFFFFFFFFFFFFFFFFFFFFF0F0');
- HPStuffHex (@AppleIcon.data[32],'0F0000000000000000000000000000F0');
- HPStuffHex (@AppleIcon.data[33],'0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0');
- HPStuffHex (@AppleIcon.data[34],'00000000000000000000000000000000');
-
- end; {of InitGlobals}
-
- END.
-